package aer.KBitsA1;

import java.math.BigInteger;
import java.util.Scanner;

public class KBitsA1Trampa {
	private static String[] a = new String[1000];
	private static final BigInteger fin = new BigInteger("1000000007");

	public static void main(String[] args) {
		rellenar();

		Scanner in = new Scanner(System.in);
		boolean b = true;

		while (b) {
			int k = in.nextInt();
			int n = in.nextInt();

			if (k <= 0 && n <= 0) {
				b = false;
			} else if (n == 0) {
				System.out.println('1');
			} else if (k == 0) {
				System.out.println('0');
			} else if (k == n) {
				System.out.println('1');
			} else {
				programa(k, n);
			}
		}

	}

	private static void programa(int k, int n) {
		// k / ( n * (k - n)! )

		BigInteger kFactorial = new BigInteger(a[k - 1]);
		BigInteger nFactorial = new BigInteger(a[n - 1]);
		BigInteger resta = new BigInteger(a[(k - n) - 1]);

		BigInteger parentesis = nFactorial.multiply(resta);
		BigInteger sol1 = kFactorial.divide(parentesis);
		BigInteger sol2 = sol1.mod(fin);

		System.out.println(sol2.toString());

	}

	private static void rellenar() {
		for (int i = 1; i <= 1000; i++) {
			a[i - 1] = factorial(i).toString();
		}
		// i + 1 + " " + a[i]

	}

	private static BigInteger factorial(int n) {
		if (n <= 1) {
			return (new BigInteger("1"));
		} else {
			BigInteger fac = new BigInteger(String.valueOf(n));
			return (fac.multiply(factorial(n - 1)));
		}
	}

}
